﻿using System;
using System.Collections.Generic;
using System.Text;
using Chloe;
using lingopen.Entity.BLE;

namespace lingopen.Application.BLE.Implements
{
    public class BLEDutyAppService : AdminAppService, IBLEDutyAppService
    {
        public PagedData<BLE_Duty> GetDutys(Pagination pagination, string keyword)
        {
            var q = this.DbContext.Query<BLE_Duty>().FilterDeleted().WhereIfNotNullOrEmpty(keyword, a => a.Name.Contains(keyword) || a.Code.Contains(keyword));
            q = q.OrderBy(a => a.Code);
            PagedData<BLE_Duty> ret = q.TakePageData(pagination);
            return ret;
        }

        /// <summary>
        /// 获取岗位的业务逻辑
        /// </summary>
        /// <returns></returns>
        public BLE_Duty_Logic GetDutyLogic(string code = "0000")
        {
            var q = this.DbContext.Query<BLE_Duty_Logic>().FilterDeleted();
            q = q.Where(a => a.Code == code);
            return q.FirstOrDefault();
        }
    }
}
